package com.designprinciple.DIP;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author Ping
 * @Date 2022/3/7 14:47
 **/
@Component
public class Driver {
   // @Autowired  // by type, in default.
//    @Qualifier("harvardCar")
    private ICar car ;
    @Autowired  // by constructor
    public Driver(ICar car) {
        this.car = car;
    }
    public void drive() {
        car.run() ;
    }
//    @Autowired
    public void setCar(ICar car) {
        this.car = car;
    }
}
